<?
class runAction extends Action {
	
	public function _initialize() {
		
		C('TOKEN_ON',FALSE);
		$ck = $_COOKIE ['ac'];
		
		//登录与帐号信息
		if ($ck ['id'] == null || $ck ['okey'] == null) {
			
			$this->redirect ( 'account/login' );
		
		} else {
			
			$o = M ( 'user' );
			$o->where ( "id = '{$ck['id']}'" );
			$r = $o->find ();
			
			$tmp = explode("\r\n",$r['cando']);
			
			$cando = implode("','",$tmp);
			$cando = "'".$cando."'";
			$this->assign('cando',$cando);
			$this->assign('user_id',$r['id']);
			
			if(!in_array(MODULE_NAME,$tmp) && $r['id']!=1 && MODULE_NAME!='Index'){
				$this->error('你没有权限管理此版块');
			}
			
			if ($ck ['okey'] != $r ['okey']) {
				$this->redirect ( 'account/login' );
			}
			
			if (strpos ( $r ['groups'], 'admin' ) === false) {
				$this->redirect ( 'account/login' );
			}
			
			$GLOBALS ['u'] = $r;
		}
		
	}
}
?>